package com.lt.integration.jpa.page;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.List;

@ApiModel("分页器")
public class Pagination<T> extends SimplePage<T> implements Serializable {
	
	private static final long serialVersionUID = 1L;

	public final static String PAGE_CONDITION_CACHE = "PageCondition";
	public final static String PAGE_CURRENT_NO_CACHE = "PageCurrentNo";
	public final static String PAGE_SIZE_CACHE = "PageSize";
	public final static String PAGE_TOTAL_COUNT_CACHE = "PageTotalCount";
	public final static String PAGE_ALL_CONDITION_CACHE = "PageAllCondition";

	public Pagination() {

	}

	public Pagination(Integer pageNo, Integer pageSize) {
		setPageSize(pageSize);
		setPageNo(pageNo);
	}

	public Pagination(int pageNo, int pageSize, long totalCount) {
		super(pageNo, pageSize, totalCount);
	}

	public Pagination(int pageNo, int pageSize, long totalCount, List<T> list) {
		super(pageNo, pageSize, totalCount);
		this.list = list;
	}
	@ApiModelProperty(hidden = true)
	private String id;
	/**
	 * 检查页码是否超过最后一页
	 */
	@ApiModelProperty(hidden = true)
	private boolean checkPassLastPageNo = true;

	/**
	 * 是否查询总条目数
	 */
	@ApiModelProperty(hidden = true)
	private boolean selectTotalCount = true;

	@ApiModelProperty(hidden = true)
	private Object condition;

	@ApiModelProperty(hidden = true)
	private Integer sort;

	public int getFirstResult() {
		return (pageNo - 1) * pageSize;
	}



	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	public String getId() {
		return id;
	}

	public Object getCondition() {
		return condition;
	}

	public void setCondition(Object condition) {
		this.condition = condition;
	}

	public void setId(String id) {
		this.id = id;
	}

	public boolean isCheckPassLastPageNo() {
		return checkPassLastPageNo;
	}

	public void setCheckPassLastPageNo(boolean checkPassLastPageNo) {
		this.checkPassLastPageNo = checkPassLastPageNo;
	}

	public boolean isSelectTotalCount() {
		return selectTotalCount;
	}

	public void setSelectTotalCount(boolean selectTotalCount) {
		this.selectTotalCount = selectTotalCount;
	}
	
}
